<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <meta http-equiv="X-UA-Compatible" content="ie=edge">
  <title>Document</title>
</head>
<body>
  
  <script src="./pubsub.js"></script>
  <script>
    const token1 = PubSub.subscribe('add', function (data) {
      console.log('add1' + data)
    })
    PubSub.subscribe('update', function (data) {
      console.log('update1' + data)
    })
    const token = PubSub.subscribe('add', function (data) {
      console.log('add2' + data)
    })
    
    PubSub.publish('add', '张三');
    PubSub.publish('update', 'update');

    PubSub.unsubscribe(token)
  </script>
</body>
</html>